﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DrugsShopManagement.DBCLASS;
using DevExpress.XtraReports.UI;

namespace DrugsShopManagement
{
    public partial class FrmDrugsOutDetail : Form
    {
        public FrmDrugsOutDetail()
        {
            InitializeComponent();
        }
        Operator op = new Operator();
        private void FrmDrugsOutDetail_Load(object sender, EventArgs e)
        {

            DataTable dt = new DataTable();
            string sql = "select drugsOutIdNum 出库单号,providerName 开票人,drugsID 药品ID,drugsName 药品名称,drugsPY 拼音码,drugsSpecification 规格,drugsBatchNo 批号,drugsStorePlace 库存地址,drugsFactory 生产厂家,drugsUsefulDate 有效期,drugsUnit 药品单位,drugsCount 库存数量,drugsInprice 进货单价,drugsSalePrice 销售单价,drugsOutNO 出库数量,drugsOutMoney 出库金额,drugsOutDate 出库日期 from drugsOut order by drugsOutId";
            dt = op.getDataTable(sql, "drugsOut");
            dataGridView1.DataSource = dt;

        }

     

   

        
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {

                XtraReport report = new XtraReport();
                string path = System.IO.Directory.GetCurrentDirectory();
                report.LoadLayout(path + "..\\..\\..\\Reports\\出库单报表.repx");
                ReportPrintTool printTool = new ReportPrintTool(report);
                //DataTable dt = new DataTable();
                DataSet ds = new DataSet();
                //string sql = "select user_id 编号,user_no 用户工号, user_name 用户姓名, user_power 用户权限, user_descripe 用户描述, user_sort 序号 from users order by user_sort";
                //dt = op.getDataTable(sql, "users");
                string sql = "select *,getdate() from drugsOut where drugsOutDT='"+dateTimePicker1.Text+"'";
                ds = op.getDataSet(sql);
                //report.DataSource = dt;
                report.DataSource = ds;
                //printTool.ShowPreview();
                //printTool.ShowRibbonPreview(UserLookAndFeel.Default);
                printTool.ShowRibbonPreview();
            }
            catch (Exception ex)
            {
                MessageBox.Show("无法打开报表，详细信息：" + ex.ToString());
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            string sql = "select drugsOutIdNum 出库单号,providerName 开票人,drugsID 药品ID,drugsName 药品名称,drugsPY 拼音码,drugsSpecification 规格,drugsBatchNo 批号,drugsStorePlace 库存地址,drugsFactory 生产厂家,drugsUsefulDate 有效期,drugsUnit 药品单位,drugsCount 库存数量,drugsInprice 进货单价,drugsSalePrice 销售单价,drugsOutNO 出库数量,drugsOutMoney 出库金额,drugsOutDate 出库日期 from drugsOut where drugsOutDT='" + dateTimePicker1.Text + "' order by drugsOutId";
            dt = op.getDataTable(sql, "drugsOut");
            dataGridView1.DataSource = dt;
        }

        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            string sql = "select drugsOutIdNum 出库单号,providerName 开票人,drugsID 药品ID,drugsName 药品名称,drugsPY 拼音码,drugsSpecification 规格,drugsBatchNo 批号,drugsStorePlace 库存地址,drugsFactory 生产厂家,drugsUsefulDate 有效期,drugsUnit 药品单位,drugsCount 库存数量,drugsInprice 进货单价,drugsSalePrice 销售单价,drugsOutNO 出库数量,drugsOutMoney 出库金额,drugsOutDate 出库日期 from drugsOut where drugsOutDT='" + dateTimePicker1.Text + "' order by drugsOutId";
            dt = op.getDataTable(sql, "drugsOut");
            dataGridView1.DataSource = dt;
        }
    }
}
